<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // ES6的类 ： 本质也是构造函数 ，只是提供了一种新的语法糖；
        class Person {
            name;
            age;
            // constructor 函数会在 实例化的时候执行；
            constructor(name, age) {
                this.name = name;
                this.age = age;
                this.fn();
            }
            get age() {
                // return this.age;
                // return 20;
                return age;
            }
            set age( newage) {
                // this.age = newage;
                age = newage;
                console.log("??",newage);
            }
            fn() {
                console.log('王俊凯',this.name);
            }
        }
        let p = new Person('周杰伦', 30);
        p.age = '50'
        console.log(p);
    </script>
</body>
</html>